package com.erli.exchange.common.sg.config;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.erli.exchange.core.util.JAXBUtil;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@XmlRootElement(name = "config")
public class GenerateConfig {

	@XmlElement(name = "baseinfo")
	private BaseInfo baseinfo;

	@XmlElement(name = "template")
	private TemplateInfo template;

	@XmlElement(name = "datasource")
	private DatasourceInfo datasource;

	@XmlElement(name = "tables")
	private TablesInfo tables;

	@XmlElement(name = "entity")
	private EntityClassInfo entity;

	@XmlElement(name = "service")
	private ServiceClassInfo service;

	@XmlElement(name = "serviceimpl")
	private ServiceImplClassInfo serviceimpl;

	@XmlElement(name = "dao")
	private DaoClassInfo dao;

	@XmlElement(name = "daoimpl")
	private DaoImplClassInfo daoimpl;

	@XmlElement(name = "mapper")
	private MapperClassInfo mapper;

	@XmlElement(name = "mapperxml")
	private MapperXmlInfo mapperxml;
	
	@XmlElement(name = "model")
	private ModelClassInfo model;

	@XmlElement(name = "converter")
	private ConverterClassInfo converter;
	
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(
				GenerateConfig.class.getClassLoader().getResourceAsStream("generate-config.xml")));
		String line = null;
		StringBuilder stringBuilder = new StringBuilder();
		while ((line = br.readLine()) != null) {
			stringBuilder.append(line);
		}
		String xml = stringBuilder.toString();
		GenerateConfig generateConfig = JAXBUtil.fromXML(GenerateConfig.class, xml);
		System.out.println(generateConfig);
		System.out.println(generateConfig.getEntity());
	}

	@XmlTransient
	public BaseInfo getBaseinfo() {
		return baseinfo;
	}

	@XmlTransient
	public TemplateInfo getTemplate() {
		return template;
	}

	@XmlTransient
	public DatasourceInfo getDatasource() {
		return datasource;
	}

	@XmlTransient
	public TablesInfo getTables() {
		return tables;
	}

	@XmlTransient
	public EntityClassInfo getEntity() {
		return entity;
	}

	@XmlTransient
	public ServiceClassInfo getService() {
		return service;
	}

	@XmlTransient
	public ServiceImplClassInfo getServiceimpl() {
		return serviceimpl;
	}

	@XmlTransient
	public DaoClassInfo getDao() {
		return dao;
	}

	@XmlTransient
	public DaoImplClassInfo getDaoimpl() {
		return daoimpl;
	}

	@XmlTransient
	public MapperClassInfo getMapper() {
		return mapper;
	}

	@XmlTransient
	public MapperXmlInfo getMapperxml() {
		return mapperxml;
	}

	@XmlTransient
	public ModelClassInfo getModel() {
		return model;
	}

	@XmlTransient
	public ConverterClassInfo getConverter() {
		return converter;
	}
	
	

}
